# 监控某一时间段/root文件夹下的变化
#
# import os
# import time
#
# class Solution():
#     def get_file(self,path):
#         while True:
#             file_list = os.listdir(path)
#             time.sleep(2)
#             file_list_2 = os.listdir(path)
#             now = time.localtime()
#             now_time = time.strftime("%Y-%m-%d %H:%M:%S", now)
#
#             if file_list_2 == file_list:
#                 continue
#             elif file_list_2 != file_list:
#                 with open('log.txt', 'a+', encoding='utf8') as fp:
#                     if len(file_list_2) > len(file_list):
#                         diff = list(set(file_list_2) - set(file_list))
#
#                         fp.write(f'{now_time},增加了文件或文件夹:{diff}\n')
#                     else:
#                         diff = list(set(file_list) - set(file_list_2))
#
#                         fp.write(f'{now_time},增加了文件或文件夹:{diff}\n')
#
# path = '/root'
# obj = Solution()
#
# obj.get_file(path)
